package com.weigee.ktv.view.fragment

import android.os.Bundle
import android.os.Handler
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.bumptech.glide.Glide
import com.linde.library.activities.MyFragmentActivity
import com.weigee.ktv.R
import com.weigee.ktv.model.enums.WeigeeHost
import com.weigee.ktv.view.activity.MainActivity
import kotlinx.android.synthetic.main.activity_welcome.*

/**
 * Created by linde on 2017/6/13.
 * LinDe
 */
class WelcomeFragment : BaseFragment()
{
    override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View?
    {
        return inflater?.inflate(R.layout.activity_welcome, container, false)
    }

    override fun onViewCreated(view: View?, savedInstanceState: Bundle?)
    {
        super.onViewCreated(view, savedInstanceState)
        Glide.with(this).load(WeigeeHost.TEST_IMAGE.url).into(iv_welcome)

        Handler().postDelayed({
            MyFragmentActivity.start(MainActivity::class.java, activity, MainFragment::class.java)
            activity.finish()
        }, 2000L)

        (activity as MyFragmentActivity).onBackPressedListener = object : MyFragmentActivity.OnBackPressedListener
        {
            override fun onBackPressed(): Boolean
            {
                return true
            }
        }
    }
}